/**
 * Copyright (c) 2013, 2018 itemis AG (http://www.itemis.eu) and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 * 
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.xtend.core.tests.compiler;

import org.eclipse.xtend2.lib.StringConcatenation;
import org.junit.Test;

/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
@SuppressWarnings("all")
public class ExtensionsCompilerTest extends AbstractXtendCompilerTest {
  @Test
  public void testDeprecatedSort() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(Iterable<String> it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("it.sort [ $0.compareTo($1) ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Comparator;");
    _builder_1.newLine();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.IterableExtensions;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final Iterable<String> it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Comparator<String> _function = (String $0, String $1) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return $0.compareTo($1);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return IterableExtensions.<String>sortWith(it, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionImportVsDefaultExtensions_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension D.*");
    _builder.newLine();
    _builder.append("import java.util.Collection");
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static <T, R> Collection<R> map(Collection<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ListExtensions;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return ListExtensions.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionImportVsDefaultExtensions_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension D.*");
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static <T, R> List<R> map(List<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return D.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVsDefaultExtensions_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import java.util.Collection");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T, R> Collection<R> map(Collection<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Collection;");
    _builder_1.newLine();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Collection<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object, R extends Object> Collection<R> map(final Collection<T> original, final Function1<? super T, ? extends R> transformation) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVsDefaultExtensions_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T, R> List<R> map(List<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object, R extends Object> List<R> map(final List<T> original, final Function1<? super T, ? extends R> transformation) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVsDefaultExtensions_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Collection");
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static def <T, R> Collection<R> map(Collection<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Collection;");
    _builder_1.newLine();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ListExtensions;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return ListExtensions.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static <T extends Object, R extends Object> Collection<R> map(final Collection<T> original, final Function1<? super T, ? extends R> transformation) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVsDefaultExtensions_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static def <T, R> List<R> map(List<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return C.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static <T extends Object, R extends Object> List<R> map(final List<T> original, final Function1<? super T, ? extends R> transformation) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionFieldVsDefaultExtensions_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Collection");
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension D");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T, R> Collection<R> map(Collection<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Collection;");
    _builder_1.newLine();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private D _d;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Collection<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this._d.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionFieldVsDefaultExtensions_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension D");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(List<String> list) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("list.map [ it ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T, R> List<R> map(List<T> original, (T)=>R transformation) { return null }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private D _d;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public List<String> m(final List<String> list) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Function1<String, String> _function = (String it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this._d.<String, String>map(list, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionAnnotations() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m(extension String s) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("extension val Double d = 1.0");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("for(extension j: 1..1) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("[ extension Object o | ");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("try {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("} catch(extension Throwable t) {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("println(t)");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("} ");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("].apply(null)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Exceptions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function1;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.InputOutput;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.IntegerRange;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(@Extension final String s) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Double d = Double.valueOf(1.0);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("IntegerRange _upTo = new IntegerRange(1, 1);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("for (@Extension final Integer j : _upTo) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Function1<Object, Throwable> _function = (Object o) -> {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Throwable _xtrycatchfinallyexpression = null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("_xtrycatchfinallyexpression = null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("} catch (final Throwable _t) {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("if (_t instanceof Throwable) {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("@Extension final Throwable t = (Throwable)_t;");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("_xtrycatchfinallyexpression = InputOutput.<Throwable>println(t);");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("} else {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("throw Exceptions.sneakyThrow(_t);");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return _xtrycatchfinallyexpression;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_function.apply(null);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class NoNPE {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension String");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def useExtension() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("_string.toString");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class NoNPE {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private String _string;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String useExtension() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this._string.toString();");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testInheritedExtensionField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("it.substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension String");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("this._string.substring(it);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = this._string.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testInheritedExtensionFieldWithAnnotation() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Extension");
    _builder.newLine();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("it.substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Extension protected String string");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("this.string.substring(it);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = this.string.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testShadowedExtensionField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension String local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension String inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected String local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.local.substring(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testOverloadedExtensionField_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension CharSequence local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("charAt");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension String inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected CharSequence local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public char m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.local.charAt(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testOverloadedExtensionField_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension A local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(CharSequence it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("ext");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension B inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(CharSequence s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(String s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected A local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final CharSequence it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("this.inherited.ext(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testOverloadedExtensionField_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension A local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(String it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("ext");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension B inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(CharSequence s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(String s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected A local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final String it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("this.local.ext(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testOverloadedExtensionField_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension B local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(CharSequence it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("ext");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension A inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(CharSequence s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(String s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected B local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final CharSequence it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("this.local.ext(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testPrivateInheritedExtensionField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected extension A local");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(String it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("ext");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension B inherited");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(CharSequence s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void ext(String s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("protected A local;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final String it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("this.local.ext(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionParameterShadowsField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension String");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it, extension String s) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private String _string;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it, @Extension final String s) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return s.substring(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionParameterWithAnnotation() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Extension");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension String");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it, @Extension String s) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private String _string;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it, @Extension final String s) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return s.substring(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionLocalShadowsParam() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it, extension String param) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val extension String s = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it, @Extension final String param) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String s = \"\";");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = s.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionLocal() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class SomeClass {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void testExtension() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("extension val ExtensionProvider x = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("\'foo\'.getName");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class ExtensionProvider {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def String getName(Object x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return x.toString");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class SomeClass {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void testExtension() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final ExtensionProvider x = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("x.getName(\"foo\");");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionVarIsLocalInBlock() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it, extension String param) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("{");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("val extension String s = \'\'");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("s.toString");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final int it, @Extension final String param) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("final String s = \"\";");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("s.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = param.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionParamOnLamdba() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("<String>newArrayList.forEach[ extension s |");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.function.Consumer;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Consumer<String> _function = (String s) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("s.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("CollectionLiterals.<String>newArrayList().forEach(_function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionParamOnForEach() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(int it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("for(extension s: <String>newArrayList) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("substring");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m(final int it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("for (@Extension final String s : _newArrayList) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("s.substring(it);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionParamOnTryCatch() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(Exception it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("try {} catch(extension RuntimeException e) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("initCause");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Exceptions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Throwable m(final Exception it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Throwable _xtrycatchfinallyexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xtrycatchfinallyexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("} catch (final Throwable _t) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("if (_t instanceof RuntimeException) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("@Extension final RuntimeException e = (RuntimeException)_t;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("_xtrycatchfinallyexpression = e.initCause(it);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("} else {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("throw Exceptions.sneakyThrow(_t);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xtrycatchfinallyexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensionForArrayOfT_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m1() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val String[] chars = newArrayList(\'foo\',\'bar\')");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("chars.at(2)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m2() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("newArrayList(\'foo\',\'bar\').at(2)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m3() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("newArrayList(\'foo\',\'bar\') => [ at(2) ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T> T at(T[] obj, int index) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return obj.get(index)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Conversions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ObjectExtensions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m1() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String[] chars = ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(\"foo\", \"bar\"), String.class));");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = this.<String>at(chars, 2);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m2() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<String>at(((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(\"foo\", \"bar\"), String.class)), 2);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public ArrayList<String> m3() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList(\"foo\", \"bar\");");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Procedure1<ArrayList<String>> _function = (ArrayList<String> it) -> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("this.<String>at(((String[])Conversions.unwrapArray(it, String.class)), 2);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return ObjectExtensions.<ArrayList<String>>operator_doubleArrow(_newArrayList, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> T at(final T[] obj, final int index) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return obj[index];");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def String m(Pair<String, String> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(\'\'->\'\').m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final Pair<String, String> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.m(Pair.<String, String>of(\"\", \"\"));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def String m(Pair<String, String> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(null->null).m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final Pair<String, String> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.m(Pair.<String, String>of(null, null));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def String m(Pair<String, String> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("in.m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final Pair<String, String> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.m(in);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T> T m(Pair<T, T> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("in.m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> T m(final Pair<T, T> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(in);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T> T m(Pair<T, T> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(null->null).m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> T m(final Pair<T, T> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(Pair.<T, T>of(null, null));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_06() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T> String m(Pair<T, T> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(\'\'->\'\').m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> String m(final Pair<T, T> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<String>m(Pair.<String, String>of(\"\", \"\"));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_07() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T extends CharSequence> T m(Pair<T, T> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("in.m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends CharSequence> T m(final Pair<T, T> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(in);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_08() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T extends CharSequence> T m(Pair<T, T> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(null->null).m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends CharSequence> T m(final Pair<T, T> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(Pair.<T, T>of(null, null));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_09() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def String m(Pair<String, String> in) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(\"\"->");
    _builder.append("\'\'\'\'\'\'", "    \t");
    _builder.append(").m");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtend2.lib.StringConcatenation;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String m(final Pair<String, String> in) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("StringConcatenation _builder = new StringConcatenation();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.m(Pair.<String, String>of(\"\", _builder.toString()));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_10() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T> String m(Pair<T, T> it) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> String m(final Pair<T, T> it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(it);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalExtensionForPairStringString_11() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.xtext.xbase.lib.Pair");
    _builder.newLine();
    _builder.append("public class C  {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def <T> String m(Pair<T, T> it) {");
    _builder.newLine();
    _builder.append("    \t");
    _builder.append("(key->value).m");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Pair;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> String m(final Pair<T, T> it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("T _key = it.getKey();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("T _value = it.getValue();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return this.<T>m(Pair.<T, T>of(_key, _value));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testStringExtensionInlined_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def String returnString(String x, String y) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("x + \'\' + y");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public String returnString(final String x, final String y) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return ((x + \"\") + y);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }
}
